/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dockfx;

import com.sun.media.jfxmedia.events.NewFrameEvent;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.Reflection;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.stage.Stage;

/**
 *
 * @author edlam
 */
public class DockFX extends Application {
    
    @Override
    public void start(Stage stage) {
        Group grpRoot = new Group();

        final ImageView imageViewDock = new ImageView(new Image("images/dockNegro.png"));
        imageViewDock.setTranslateX(100);
        imageViewDock.setTranslateY(200);
        imageViewDock.setOnMouseClicked(new javafx.event.EventHandler<MouseEvent>(){

            @Override
            public void handle(MouseEvent t) {
                if(t.getButton() == MouseButton.PRIMARY){
                    imageViewDock.setImage(new Image("images/dock.png"));
                }else{
                    imageViewDock.setImage(new Image("images/dockNegro.png"));
                }
            }
        });

        grpRoot.getChildren().add(imageViewDock);
        
        final String[] images = {
            "Browser-32.png",
            "Internet-32.png",
            "Mail-32.png",
            "User-32.png"
        };
        
        for(int i = 0; i < images.length; i++){
            final ImageView imgViewIcon = new ImageView(new Image("images/" + images[i]));
            imgViewIcon.setTranslateX(170 + 50 * i);
            imgViewIcon.setTranslateY(200);
            imgViewIcon.setEffect(new Reflection());
            imgViewIcon.setOnMouseEntered(new EventHandler<MouseEvent>(){

                @Override
                public void handle(MouseEvent t) {
                    imgViewIcon.setScaleX(1.2);
                    imgViewIcon.setScaleY(1.2);
                }
                
            
            });
            imgViewIcon.setOnMouseExited(new EventHandler<MouseEvent>(){

                @Override
                public void handle(MouseEvent t) {
                    imgViewIcon.setScaleX(1.0);
                    imgViewIcon.setScaleY(1.0);
                }
                
            
            });
            grpRoot.getChildren().add(imgViewIcon);
        }
        
        Scene scene = new Scene(grpRoot, 550, 300);               
        stage.setScene(scene);
        stage.setTitle("DockFX");
        stage.show();
    }

    /**
     * The main() method is ignored in correctly deployed JavaFX application.
     * main() serves only as fallback in case the application can not be
     * launched through deployment artifacts, e.g., in IDEs with limited FX
     * support. NetBeans ignores main().
     *
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        launch(args);
    }
}
